import os
import sys
import django
import datetime


# 环境变量

sys.path.append(r'C:\Users\82628\Desktop\MIS\MIS')

os.chdir(r'C:\Users\82628\Desktop\MIS\MIS')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MIS.settings")
django.setup()

# 这一行的位置不能变，千万别把这个应用扔到开头去
from production_ms.models import *
from django.db.models import *


from django.db import connection
from django.db import connections

# with connection.cursor() as cursor:
with connections['production'].cursor() as cur:
    cur.execute(f'''
        select DISTINCT unit from down1 where date = '2021-10-10'
    ''')
    data2_crew = cur.fetchall()
    data2_crew = list(map(lambda i: i[0], data2_crew))
    #
    #
    # cur.execute("select * from production_ms_down where date > '2021-09-09' and date < '2021-09-15'")
    # row = cur.fetchone()
    print(data2_crew)
